<?php

/**
 * This is the model class for table "{{ad_groups}}".
 *
 * The followings are the available columns in table '{{ad_groups}}':
 * @property integer $ad_gid
 * @property integer $site_id
 * @property string $code
 * @property string $group_name
 * @property integer $ads_count
 */
class AdGroups extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return AdGroups the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{ad_groups}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('site_id', 'required'),
			array('site_id, ads_count', 'numerical', 'integerOnly'=>true),
			array('code', 'length', 'max'=>32),
			array('group_name', 'length', 'max'=>30),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ad_gid, site_id, code, group_name, ads_count', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ad_gid' => 'Ad Gid',
			'site_id' => 'Site',
			'code' => 'Code',
			'group_name' => 'Group Name',
			'ads_count' => 'Ads Count',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ad_gid',$this->ad_gid);
		$criteria->compare('site_id',$this->site_id);
		$criteria->compare('code',$this->code,true);
		$criteria->compare('group_name',$this->group_name,true);
		$criteria->compare('ads_count',$this->ads_count);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}